package com.x9space.framework.config.properties;

import com.x9space.common.utils.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * @author 忘忧症
 * @Distribute
 */

@ConfigurationProperties(prefix = "spring.datasource.elasticsearch")
@Component
public class ElasticsearchProperties {

    private String host;
    private Integer port;
    private String scheme;
    private String username;
    private String password;

    public void setHost(String host) {
        this.host = host;
    }
    public void setPort(Integer port) {
        this.port = port;
    }
    public void setScheme(String scheme) {
        this.scheme = scheme;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public void setPassword(String password) {
        this.password = password;
    }


    public String getHost() {
        if (StringUtils.isEmpty(host)){
            return "localhost";
        }
        return host;
    }


    public Integer getPort() {
        if (port==null){
            return 9200;
        }
        return port;
    }



    public String getScheme() {
        if (StringUtils.isEmpty(scheme)){
            return "http";
        }

        return scheme;
    }


    public String getUsername() {
        return username;
    }


    public String getPassword() {
        return password;
    }


}
